package configuration.dataObjects
{
	import common.utils.DateManager;
	
	import mx.collections.ArrayCollection;
	[Bindable]
	public class GenericConfigDetailDO
	{
				
		public var RECORD_TYPE:String = "";
		public var IDENTIFIER:String = "";
		public var DESCRIPTION:String = "";
		public var SYSTEM_CREATED:String = "N";
		public var VALUE1:String = "";
		public var VALUE2:String = "";
		public var VALUE3:String = "";
		public var VALUE4:String = "";
		public var ACTIVE:String = "Y";
		public var USER_STAMP:String = "";
		public var DATE_TIME_STAMP:String = DateManager.GetTodayString();
		public var OBJECT_ID:Number = 0;
		public var SEQUENCE:Number = 0;
		
		public function GenericConfigDetailDO()
		{
		}

		public function Init(xmlObj:XML):void{
			if(null == xmlObj)
				return;
			else{
				for each (var itemProp:XML in xmlObj.children()) {			
					this[itemProp.name()] = itemProp;
				}
			}
		}
		
		public function ToXML():XML{
			var xmlObj:XML =
			<GENERIC_CONFIG_DETAIL>
				<RECORD_TYPE>{RECORD_TYPE}</RECORD_TYPE>
				<IDENTIFIER>{IDENTIFIER}</IDENTIFIER>
				<DESCRIPTION>{DESCRIPTION}</DESCRIPTION>
				<SYSTEM_CREATED>{SYSTEM_CREATED}</SYSTEM_CREATED>
				<VALUE1>{VALUE1}</VALUE1>
				<VALUE2>{VALUE2}</VALUE2>
				<VALUE3>{VALUE3}</VALUE3>
				<VALUE4>{VALUE4}</VALUE4>
				<ACTIVE>{ACTIVE}</ACTIVE>
				<USER_STAMP>{USER_STAMP}</USER_STAMP>
				<DATE_TIME_STAMP>{DATE_TIME_STAMP}</DATE_TIME_STAMP>
				<OBJECT_ID>{OBJECT_ID}</OBJECT_ID>
				<SEQUENCE>{SEQUENCE}</SEQUENCE>			
			</GENERIC_CONFIG_DETAIL>;
			return xmlObj;
		}
		
		public static function getItems(list:XMLList):ArrayCollection
		{
			var ac:ArrayCollection = new ArrayCollection();
			for each(var xml:XML in list)
			{
				var itm:GenericConfigDetailDO = new GenericConfigDetailDO();
				itm.Init(xml);
				ac.addItem(itm);
			}
			return ac;
		}
	}
}